using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Blood_Siege.Managers
{
    public enum GameStates
    {
        Battle,
        Credits,
        HighScore,
        LoadGame,
        Map,
        Menu,
        Multiplayer,
        NewGame,
        Options,
        Quickplay
    }

    public class GameStatesMachine : StateMachine<GameStates>
    {
           protected override IEnumerable<GameStates> ConfigureStates()
           {
               while (true)
               {
                   yield return GameStates.Battle;
                   yield return GameStates.Credits;
                   yield return GameStates.HighScore;
                   yield return GameStates.LoadGame;
                   yield return GameStates.Map;
                   yield return GameStates.Menu;
                   yield return GameStates.Multiplayer;
                   yield return GameStates.NewGame;
                   yield return GameStates.Options;
                   yield return GameStates.Quickplay;
               }
           }
    }

    public abstract class StateMachine<TState>
       {
           private IEnumerator<TState> _enumerator;
  
           public void Start()
           {
               _enumerator = ConfigureStates().GetEnumerator();
               _enumerator.MoveNext();
           }
  
           public TState CurrentState
           {
               get { return _enumerator.Current; }
           }
  
           protected void SwitchStates(GameStates newState)
           {
               while(_enumerator.Current.Equals(newState) == false)
               {
                   _enumerator.MoveNext();
               }
           }
  
           protected abstract IEnumerable<TState> ConfigureStates();
       }
}
